package com.onedec.menu.service.impl;

import com.onedec.menu.dao.OnedecDeptDao;
import com.onedec.menu.entity.OnedecDept;
import com.onedec.menu.entity.OnedecDeptExample;
import com.onedec.menu.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class DeptServiceImpl implements DeptService {
    @Autowired
    private OnedecDeptDao onedecDeptDao;
    @Override
    public List<OnedecDept> selectAll() {
        return onedecDeptDao.selectByExample(null);
    }

    @Override
    public void insert(OnedecDept onedecDept) {
        onedecDeptDao.insertSelective(onedecDept);
    }

    @Override
    public List<OnedecDept> selectByName(String name) {
        OnedecDeptExample onedecDeptExample = new OnedecDeptExample();
        OnedecDeptExample.Criteria or = onedecDeptExample.or();
        or.andDeptNameEqualTo(name);
        return onedecDeptDao.selectByExample(onedecDeptExample);
    }
}
